package com.swanclouds.redfish.managers;

import com.google.common.base.Preconditions;
import com.swanclouds.api.managers.NtpService;
import com.swanclouds.core.transport.ClientConstants;
import com.swanclouds.model.managers.Ntp;
import com.swanclouds.redfish.internal.BaseManagerService;
import com.swanclouds.redfish.managers.domain.NtpModel;
import com.swanclouds.redfish.managers.domain.NtpServiceModel;

public class NtpServiceImpl extends BaseManagerService implements NtpService {

    /**
     * 查询NTP资源详情信息
     * @return Ntp
     */
    @Override
    public Ntp get() {
        return get(NtpServiceModel.class,uri(ClientConstants.PATH_MANAGERS_NTPSERVICE,getManagerId())).execute();
    }

    /**
     * 修改服务器NTP资源属性
     * @param ntpModel 修改服务器NTP资源属性参数
     * @return ActionResponse
     */
    @Override
    public Ntp updateNtpService(NtpModel ntpModel) {
        Preconditions.checkNotNull(ntpModel,"ntpModel is null");
        //先查询一下,确保获取到的etg是最新的
        get();
        return patch(NtpServiceModel.class,uri(ClientConstants.PATH_MANAGERS_NTPSERVICE,getManagerId()))
                .entity(ntpModel)
                .execute();
    }
}
